<template>
  <a-modal
    :title="title"
    width="50%"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
    destroyOnClose
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="代理名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入代理名称"
            v-decorator="['agentName', {
              initialValue: banner.agentName,
              rules: [{required: true, message: '请输入代理名称'}]}]"
          />


        </a-form-item>
        <a-form-item label="用户名" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入用户名"
            v-decorator="['username', {
              initialValue: banner.username,
              rules: [{required: true, message: '请输入用户名'}]}]"
          />
        </a-form-item>
        <a-form-item label="手机号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入手机号"
            v-decorator="['phone', {
              initialValue: banner.phone,
              rules: [{required: true, message: '请输入手机号'}]}]"
          />
        </a-form-item>
        <!-- <a-form-item label="渠道价格" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            suffix="%"
            placeholder="请输入渠道价格"
            v-decorator="['feeRate', {
              initialValue: banner.feeRate,
              rules: [{required: true, message: '请输入渠道价格'}],}]"
          />
        </a-form-item>


        <a-form-item
          label="发票类型"
          :labelCol="{lg: {span: 7}, sm: {span: 7}}"
          :wrapperCol="{lg: {span: 10}, sm: {span: 17} }"
        >
          <a-select
            v-decorator="[
              'invoiceType',
              { initialValue: banner.invoiceType,
                rules: [{ required: true, message: '请选择发票类型' }]}
            ]"
            name="invoiceType"
            placeholder="请选择发票类型"
            @change="handleChange1"
          >
            <a-select-option :key="1">增值税普通发票</a-select-option>
            <a-select-option :key="2">增值税专用发票</a-select-option>
            <a-select-option :key="3">增值税差额普票</a-select-option>
            <a-select-option :key="4">增值税普通发票/增值税专用发票</a-select-option>
          </a-select>
        </a-form-item> -->
        <a-form-item label="渠道价" :labelCol="labelCol" 
            :wrapperCol="{
            xs: { span: 24 },
            sm: { span: 17 }
          }" required>
              
              <a-table
                v-show="feeRateList.length > 0"
                :columns="columns"
                rowKey="key"
                :pagination="false"
                :data-source="feeRateList"
                size="small"
              >
              <span
                  slot="invoiceType"
                  slot-scope="text"
                >
                <template v-if="text == 1">增值税普通发票</template>
                <template v-if="text == 2">增值税专用发票</template>
                <template v-if="text == 3">增值税差额普票</template>
                <template v-if="text == 4">增值税普通发票/增值税专用发票</template>
                </span>
                <span
                  slot="action"
                  slot-scope="text, record, index"
                >
                <a @click="editList(record, index)">编辑</a>
                <a-divider type="vertical"/>
                <a @click="delList(record, index)">删除</a>
                  
                 
                </span>
              </a-table>
              <a-button @click="addList()" v-if="feeRateList.length < 4">
                <a-icon type="plus" />新增
              </a-button>
          </a-form-item>  
        <a-form-item label="销售人员" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            disabled
            v-decorator="['salesName', {
              initialValue: banner.salesName,
              rules: [{required: true, message: '请输入销售人员姓名'}]}]"
          />
        </a-form-item>
        <a-form-item label="运营人员" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            disabled
            placeholder="请输入运营人员姓名"
            v-decorator="['operationsManagerName', {
              initialValue: banner.operationsManagerName,
              rules: [{required: true, message: '请输入运营人员姓名'}]}]"
          />
<!--          <a-select-->
<!--            :allowClear="true"-->
<!--            :show-search="true"-->
<!--            v-decorator="['operationsManagerName', {-->
<!--              initialValue: banner.operationsManagerName,-->
<!--              rules: [{required: true, message: '请输入运营人员姓名'}]}]"-->
<!--            name="operationsManagerName"-->
<!--            placeholder="请输入运营人员姓名"-->
<!--            @onchange="handleChange_yunying">-->
<!--            <a-select-option-->
<!--              v-for="item in yyOptions"-->
<!--              :key="item.realName">-->
<!--              {{ item.realName}}-->

<!--            </a-select-option>-->
<!--          </a-select>-->

        </a-form-item>
        <a-form-item
          label="代理商合同"
          :labelCol="{lg: {span: 7}, sm: {span: 2}}"
          :wrapperCol="{lg: {span: 7}, sm: {span: 22} }"
        >
          <div v-if="form.getFieldValue('agentContract')">
            <a @click="downloadAttachment(form.getFieldValue('agentContract'))">{{ form.getFieldValue('agentContract') }}</a>
            <span>&nbsp;
            <a-icon
              type="close"
              @click="removeConfirmationFile"
            /></span>
          </div>
          <a-upload
            v-else
            name="mediaFile"
            :showUploadList="false"
            :before-upload="beforeUploadConfirmationFile"
          >
            <a-button
              :loading="confirmationUploading"
            >
              <a-icon type="upload" />上传代理商合同
            </a-button>
            <a-button
              :loading="confirmationUploading"
              v-if="this.agentContract!=null"
              :disabled="false"
              @click="downloadAttachment(form.getFieldValue('agentContract'))">{{ form.getFieldValue('agentContract') }}
              <a-icon type="file"/>查看代理商合同
            </a-button>
          </a-upload>
          <a-input
            hidden
            v-decorator="[
            'agentContract',
            {initialValue: banner.agentContract,
              rules: [{ required: false, message: '请上传代理商合同' }]}
          ]"
          />
        </a-form-item>
        <a-form-item
          label="代理类型"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <a-radio-group
            v-decorator="['agentType', {
                initialValue: banner.agentType,
                rules: [{required: true, message: '请选择代理类型'}]}]"
            @change="setagentType"
          >
            <a-radio :value="1">个人</a-radio>
            <a-radio :value="2">公司</a-radio>
          </a-radio-group>
        </a-form-item>
        <a-form-item
          v-if="agentType === 1"
          label="身份证复印件"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <a-upload
            name="individualIdcardImage"
            list-type="picture-card"
            class="avatar-uploader"
            :show-upload-list="false"
            :before-upload="beforeUploadbeforeUploadImage"
          >
            <img
              v-if="this.methodsActionType===1 || form.getFieldValue('individualIdcardImage')"
              :src="this.individualIdcardImageUrl || imageUrlPrefix + form.getFieldValue('individualIdcardImage')"
              alt="individualIdcardImage"
              style="max-width: 100%;"
            />
            <div v-else>
              <a-icon :type="uploadLoading ? 'loading' : 'plus'" />
              <div class="ant-upload-text">{{ uploadLoading ? '上传中' : '上传' }}</div>
            </div>
          </a-upload>
          <a-input
            hidden
            v-decorator="[
                'individualIdcardImage',
                {initialValue: banner.individualIdcardImage,
                  rules: [{ required: true, message: '请上传身份证复印件图片' }]}
              ]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 1"
          label="姓名"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入个人名称"
            v-decorator="['individualName', {
              initialValue: banner.individualName,
              rules: [{required: true, message: '请输入个人名称'}]}]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 1"
          label="银行卡号"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入银行卡号"
            v-decorator="['individualBankCardNum', {
              initialValue: banner.individualBankCardNum,
              rules: [{required: true, message: '请输入银行卡号'}]}]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 1"
          label="开户行"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入开户行"
            v-decorator="['individualBankName', {
              initialValue: banner.individualBankName,
              rules: [{required: true, message: '请输入银行卡号'}]}]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 1"
          label="身份证号"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入身份证号"
            v-decorator="['individualIdCardNum', {
              initialValue: banner.individualIdCardNum,
              rules: [{required: true, message: '请输入身份证号'}]}]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 2"
          label="法人身份证复印件"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <a-upload
            name="corporationIdcardImage"
            list-type="picture-card"
            class="avatar-uploader"
            :show-upload-list="false"
            :before-upload="beforeUploadCorporationIdcardImage"
          >
            <img
              v-if="this.methodsActionType===2 || form.getFieldValue('corporationIdcardImage')"
              :src="this.corporationIdcardImageUrl || imageUrlPrefix + form.getFieldValue('corporationIdcardImage')"
              alt="corporationIdcardImage"
              style="max-width: 100%;"
            />
            <div v-else>
              <a-icon :type="uploadLoading ? 'loading' : 'plus'" />
              <div class="ant-upload-text">{{ uploadLoading ? '上传中' : '上传' }}</div>
            </div>
          </a-upload>
          <a-input
            hidden
            v-decorator="[
                'corporationIdcardImage',
                {initialValue: banner.corporationIdcardImage,
                  rules: [{ required: true, message: '请上传法人身份证复印件图片' }]}
              ]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 2"
          label="营业执照"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <a-upload
            name="licenseImage"
            list-type="picture-card"
            class="avatar-uploader"
            :show-upload-list="false"
            :before-upload="beforeUploadLicenseImage"
          >
            <img
              v-if="this.methodsActionType===2 || form.getFieldValue('licenseImage')"
              :src="this.licenseImageUrl || imageUrlPrefix + form.getFieldValue('licenseImage')"
              alt="licenseImage"
              style="max-width: 100%;"
            />
            <div v-else>
              <a-icon :type="uploadLoading ? 'loading' : 'plus'" />
              <div class="ant-upload-text">{{ uploadLoading ? '上传中' : '上传' }}</div>
            </div>
          </a-upload>
          <a-input
            hidden
            v-decorator="[
                'licenseImage',
                {initialValue: banner.licenseImage,
                  rules: [{ required: true, message: '请上传营业执照图片' }]}
              ]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 2"
          label="账户"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入账户"
            v-decorator="['enterpriseAccount', {
              initialValue: banner.enterpriseAccount,
              rules: [{required: true, message: '请输入账户'}]}]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 2"
          label="账号"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入账号"
            v-decorator="['enterpriseAccountNum', {
              initialValue: banner.enterpriseAccountNum,
              rules: [{required: true, message: '请输入账号'}]}]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 2"
          label="开户行"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入开户行"
            v-decorator="['enterpriseBankName', {
              initialValue: banner.enterpriseBankName,
              rules: [{required: true, message: '请输入开户行'}]}]"
          />
        </a-form-item>
        <a-form-item
          v-if="agentType === 2"
          label="联行号"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入联行号"
            v-decorator="['enterpriseUnionBankNum', {
              initialValue: banner.enterpriseUnionBankNum,
              rules: [{required: true, message: '请输入联行号'}]}]"
          />
        </a-form-item>


        <a-form-item label="密码" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入密码"
            v-decorator="['password', {
              initialValue: banner.password}]"
          />
        </a-form-item> 
        <a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-textarea
            placeholder="请输入备注"
            v-decorator="['remark', {
              initialValue: banner.remark}]"
          />
        </a-form-item>
        <a-form-item label="有效否" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-radio-group v-decorator="['effective', {
              initialValue: banner.effective}]">
            <a-radio value="1">有效</a-radio>
            <a-radio value="0">无效</a-radio>
          </a-radio-group>
        </a-form-item>
      </a-form>
    </a-spin>
    <a-modal 
    :title="title1"
    width="50%"
    :visible="visible1"
    :confirmLoading="confirmLoading1"
    @ok="addFeilv"
    @cancel="visible1 = false"
    destroyOnClose
    >
    <a-form :form="form1">
      <a-form-item label="渠道价" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                suffix="%"
                placeholder="请输入渠道价"
                v-decorator="['feeRate', {
                  initialValue: feeRateInfo.feeRate,
                  rules: [{required: true, message: '请输入渠道价'}]}]"
              />
            </a-form-item>  
            <a-form-item
            style="flex: 1;"
              label="发票类型"
              :labelCol="labelCol" :wrapperCol="wrapperCol"
            >
              <a-select
                v-decorator="[
                  'invoiceType',
                  { initialValue: feeRateInfo.invoiceType,
                    rules: [{ required: true, message: '请选择发票类型'},
                    {required: true,validator: handleInvoiceTypeVarify, trigger:'change'}]}
                ]"
                name="invoiceType"
                placeholder="请选择发票类型"
                @change="handleChange1"
              >
                <a-select-option  v-for="item in alliInvoiceTypeInfo"  :key="item.id">{{item.name}}</a-select-option>
              </a-select>
            </a-form-item>
    </a-form>
    </a-modal>
  </a-modal>
</template>

<script>
import {uploadImage, getMenuTree, getAuthorities, uploadProjectFile, uploadDeliveryFile, getAgent} from '@/api/manage'
import config from '@/config/defaultSettings'
import banner from '@/views/system/banner'
import { downloadAttachment } from '@/utils/util'
const initialBannerValue = {
  individualName: '',
  individualBankCardNum: '',
  individualBankName: '',
  individualIdCardNum: '',
  enterpriseAccount:'',
  enterpriseAccountNum:'',
  enterpriseBankName:'',
  enterpriseUnionBankNum:'',
  agentContract:'',
  agentName: '',
  effective: '',
   password: '',
  phone: '',
  remark: '',
  username: '',
  //feeRate:'',
  //invoiceType:'',
  feeRateList: [],
  salesName:'',
  operationsManagerName:'',
  agentType:'',
  individualIdcardImage:'',
  licenseImage:'',
  corporationIdcardImage:''
}
export default {
  data() {
    return {
      visible1: false,
      confirmLoading1: false,
      confirmationUploading: false,
      confirmationFile: null,
      title: '新增下级代理商',
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 13 }
      },
      form: this.$form.createForm(this),
      form1: this.$form.createForm(this),
      visible: false,
      isTrue: true,
      confirmLoading: false,
      confirmAction: null,
      banner: initialBannerValue,
      okArr: [],
      agentType: 1,
      imageUrlPrefix: config.uploadedUrlPrefix,
      individualIdcardImageUrl: '',
      corporationIdcardImageUrl: '',
      licenseImageUrl: '',
      uploadLoading: false,
      methodsActionType: null,
      agentContract:null,
      // selectValue: undefined,
      feeRateList: [],
      feeRateInfo: {
          invoiceType: undefined,
          feeRate: ''
      },
      columns: [
        {
          title: '渠道价',
          dataIndex: 'feeRate',
          customRender: (text, row, index) => {
            if (text!=null){
              switch (text) {
                default:
                  return text+'%'
              }
            }
          }
        },
        {
          title: '发票类型',
          dataIndex: 'invoiceType',
          scopedSlots: { customRender: 'invoiceType' },
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
        }
      ],
      invoiceTypeList: [
        {
          id: 1,
          name: '增值税普通发票'
        },
        {
          id: 2,
          name: '增值税专用发票'
        },
        {
          id: 3,
          name: '增值税差额普票'
        },
        {
          id: 4,
          name: '增值税普通发票/增值税专用发票'
        }
      ],
      alliInvoiceTypeInfo: [
      {
          id: 1,
          name: '增值税普通发票'
        },
        {
          id: 2,
          name: '增值税专用发票'
        },
        {
          id: 3,
          name: '增值税差额普票'
        },
        {
          id: 4,
          name: '增值税普通发票/增值税专用发票'
        }
      ],
      currentIndex: -1,
      title1: '新增'
    }
  },
  created() {
      this.getAgent()
  },
  methods: {

    delList (record, index) {
      console.log(record)
      console.log(index)
      this.feeRateList.splice(index, 1)
      this.alliInvoiceTypeInfo.forEach((item, index) => {
        if (item.id == record.invoiceType) {
          this.invoiceTypeList.push(item)
        }
      })
    },
    addList () {
      this.title1 = '新增'
      this.visible1 = true
      this.currentIndex = -1
      this.feeRateInfo = {
        invoiceType: undefined,
        feeRate: ''
      }
    },
    editList (record, index) {
      this.title1 = '修改'
      this.visible1 = true
      this.feeRateInfo = record
      this.form1.setFieldsValue({
        invoiceType: record.invoiceType,
        feeRate: record.feeRate
      })
      this.currentIndex = index
    },
    addFeilv () {
      const {
        confirmAction,
        form1: { validateFields }
      } = this
      validateFields((errors, values) => {
        console.log(errors)
        console.log(values)
        if (!errors) {
          const obj = {
            invoiceType: values.invoiceType,
            feeRate: values.feeRate
          }
          if (this.title1 == '新增') {
            this.feeRateList.push(obj)
          } else {
            this.$set(this.feeRateList, this.currentIndex, obj)
            // this.feeRateList[this.currentIndex] = obj
          }
          
          
          this.visible1 = false
          this.currentIndex = -1
          this.invoiceTypeList.forEach((item, index) => {
            if (item.id == obj.invoiceType) {
              this.invoiceTypeList.splice(index, 1)
            }
          })
        }
      })
    },
    handleInvoiceTypeVarify(rule, value, callback) {
      var checked = false
      let num = 0

      this.feeRateList.forEach((item, index) => {
        num = num + 1
        if (item.invoiceType == value) {
          if (index == this.currentIndex) {
            checked = false
          } else {
            checked = true
          }
        }
      })
      if (num == this.feeRateList.length) {
          if (checked == false) {
            callback()
          } else if (checked == true) {
            callback(new Error('发票类型已添加，请重新选择！'))
          }
      }
     
    },
    //为了让销售运营固定  获取代理的信息
    getAgent(){
      getAgent().then(res => {
        console.log('代理数据是')
        console.log(res.resData['operationsManagerName'])
        this.banner.operationsManagerName = res.resData['operationsManagerName']
        this.banner.salesName=res.resData['salesName']
        // this.salesName= res.resData
      })
    },
    beforeUploadFile(file) {
      this.file = file
      this.handleFileUploadContract('agentContract',this.uploadLoading,this.file)
      return false
    },
    beforeUploadConfirmationFile(file) {
      this.confirmationFile = file
      this.handleFileUploadContract('agentContract',this.confirmationUploading,this.confirmationFile)
      return false
    },
    removeConfirmationFile() {
      this.confirmationFile = null
      this.form.resetFields('agentContract')
    },
    downloadAttachment,
    beforeUploadbeforeUploadImage(file) {
      const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
      this.file = file
      if (!isJpgOrPng) {
        this.$message.error('只能上传JPG或PNG图片！')
      }
      const isLt2M = file.size / 1024 / 1024 < 10
      if (!isLt2M) {
        this.$message.error('图片需小于10M')
      }
      if (isJpgOrPng && isLt2M) {
        this.handleFileUpload('individualIdcardImage')
      }
      return false
    },
    beforeUploadCorporationIdcardImage(file) {
      const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
      this.file = file
      if (!isJpgOrPng) {
        this.$message.error('只能上传JPG或PNG图片！')
      }
      const isLt2M = file.size / 1024 / 1024 < 10
      if (!isLt2M) {
        this.$message.error('图片需小于10M')
      }
      if (isJpgOrPng && isLt2M) {
        this.handleFileUpload('corporationIdcardImage')
      }
      return false
    },
    beforeUploadLicenseImage(file) {
      const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
      this.file = file
      if (!isJpgOrPng) {
        this.$message.error('只能上传JPG或PNG图片！')
      }
      const isLt2M = file.size / 1024 / 1024 < 10
      if (!isLt2M) {
        this.$message.error('图片需小于10M')
      }
      if (isJpgOrPng && isLt2M) {
        this.handleFileUpload('licenseImage')
      }
      return false
    },
    handleFileUpload(fieldName) {
      const formData = new FormData()
      formData.append('imageFile', this.file)
      this.uploadLoading = true
      uploadImage(formData).then(res => {
        console.log(res)
        const result = res.resData && res.resData.result
        this.form.setFieldsValue({
          [fieldName]: res.resData && res.resData.result
        })
        console.log(this.form.getFieldsValue().individualIdcardImage)
        
        console.log(fieldName)
        if (fieldName == 'licenseImage') {
          this.licenseImageUrl = this.imageUrlPrefix + result
        }
        if (fieldName == 'individualIdcardImage') {
          this.individualIdcardImageUrl = this.imageUrlPrefix + result
        }
        if (fieldName == 'corporationIdcardImage') {
          this.corporationIdcardImageUrl = this.imageUrlPrefix + result
        }
        // {{form.getFieldValue('corporationIdcardImage')}}
      }).catch((err) => {
        console.log(err)
        this.file = null
        this.$message.error('上传失败，请重试')
      }).finally(() => {
        this.uploadLoading = false
      })
    },
    handleFileUploadContract(fieldName,uploadLoading,file) {
      const formData = new FormData()
      formData.append('deliveryFile', file)
      uploadLoading = true
      uploadProjectFile(formData).then(res => {
        const filename = res.resData && res.resData.result
        this.form.setFieldsValue({
          [fieldName]: filename
        })
      }).catch(() => {
        file = null
        this.$message.error('上传失败，请重试')
      }).finally(() => {
        uploadLoading = false
      })
    },
    setagentType(event) {
      this.agentType = event.target.value
    },
    handleChange1(value) {
      console.log(value)
      this.invoiceType = value
    },
    handleSubmit() {
      const {
        confirmAction,
        form: { validateFields }
      } = this
     
      validateFields((errors, values) => {
        if (!errors) {
          console.log('提交的信息是')
          if (this.feeRateList.length == 0) {
            this.$message.error('请添加代理商费率')
            return
          }
          this.confirmLoading = true
          this.banner.feeRateList = this.feeRateList
          confirmAction({ ...this.banner, ...values }, () => {
            this.confirmLoading = false
            this.handleCancel()
          })
        } else {
          this.confirmLoading = false
        }
      })
    },
    show(confirmAction, methodsAction, banner = initialBannerValue) {
      this.feeRateList = []
      this.invoiceTypeList = JSON.parse(JSON.stringify(this.alliInvoiceTypeInfo))
      this.visible = true
      this.confirmAction = confirmAction
      if (methodsAction) {
        //修改
        this.title = '编辑下级代理商'
        this.agentType=methodsAction.agentType
        this.methodsActionType=methodsAction.agentType
        if (methodsAction.individualIdcardImage) {
          this.individualIdcardImageUrl='https://xyg-pub.oss-cn-beijing.aliyuncs.com/'+methodsAction.individualIdcardImage
        }
        if (methodsAction.corporationIdcardImage) {
          this.corporationIdcardImageUrl='https://xyg-pub.oss-cn-beijing.aliyuncs.com/'+methodsAction.corporationIdcardImage
        }
        if (methodsAction.licenseImage) {
          this.licenseImageUrl='https://xyg-pub.oss-cn-beijing.aliyuncs.com/'+methodsAction.licenseImage
        }
        this.agentContract=methodsAction.agentContract
        this.banner= methodsAction
        this.feeRateList = methodsAction.feeRateList
        console.log(methodsAction)
        
        if (this.feeRateList.length > 0) {
          this.feeRateList.forEach(item => {
            this.invoiceTypeList.forEach((item1, index1) => {
              if (item.invoiceType == item1.id) {
                this.invoiceTypeList.splice(index1, 1)
              }
            })
          })
        }
        if (methodsAction.agentType===1){
          this.banner.enterpriseAccount=''
          this.banner.enterpriseAccountNum=''
          this.banner.enterpriseUnionBankNum=''
          this.banner.enterpriseBankName=''
        }
        if (methodsAction.agentType===2){
          this.banner.individualBankName=''
          this.banner.individualName=''
          this.banner.individualIdCardNum=''
          this.banner.individualBankCardNum=''
        }
      } else {
        //新增
        this.agentType=1
        this.methodsActionType = 0
        this.individualIdcardImageUrl=''
        this.corporationIdcardImageUrl=''
        this.licenseImageUrl=''
        this.title = '新增下级代理商'
        this.agentContract=null
        this.banner = banner
      }

      console.log(banner)
    },
    handleCancel() {
      this.visible = false
      this.checkedKeys = []
    }
  }
}
</script>
